'use strict'
let SUN = require('../base/sun')
let serverConfig = SUN.serConfig.serverConfig
let db = require('./db')

class IdsDao {
    constructor() {}
    findOneAndUpdate(fieldname, callback) {
        db.ids.update({
            _id: serverConfig.serverId
        }, {
            $inc: {
                [fieldname]: 1
            }
        }, {
            upsert: true,
            returnUpdatedDocs: true
        }, callback)
    }
}

let idsDao = new IdsDao()
module.exports = idsDao
